// pages/clickMe/plan/agreelist.js
import api from '../../../api/index'
import { userInfoStore } from '../../../store/userInfo'
const app = getApp();

Page({

  /**
   * 页面的初始数据
   */
  data: {
    userLevel: 0,
    selectStatus:-1,
    contracts:[],
    
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({ userLevel: userInfoStore.userInfo.level })
    
    
  },

  onShow: function (){
    this.getContractList();
  },

  getContractList:function() {
    let param = {
      openId: userInfoStore.userInfo.openId
      // openId: 'ofhiR4r5gZQzXTEMHF2uwiTGwosc'
    }
    if (this.data.selectStatus != -1) {
      param = Object.assign(param, { status: this.data.selectStatus})
    }
    let self=this
    api.getContractList(param).then(res => {
      //console.log(res)
      let { result } = res;
      self.setData({ contracts: result })
    })
  },

  switchItem:function(e){
    let s = e.currentTarget.dataset.status;
    let self = this
    this.setData({
      selectStatus: s
    }, ()=>{
      self.getContractList();
    });
  },
  

  dialogConfirm: function (e) {
    let self = this
    
  },

  

  showDetail:function(e){
    let id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: 'agree?id='+id,
    })
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    
  }
})